package com.feeyo.monitor.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

/**解析类工具类
 * @Author <a href="mailto:bliulei@variflight.com">liulei</a>
 * @Description Created by liulei on 2017/5/15 下午6:02.
 */
public class ParseUtils {
	public static Map parsePermsMap(Map perm){
		Map<String,Object> param = new HashMap<>();
		Iterator<Entry<Object, Object>> iter = perm.entrySet().iterator();
		while (iter.hasNext()) {
			Map.Entry entry = iter.next();
			Object key = entry.getKey();
			if (key.equals("id") || key.equals("monitorVisit") || key.equals("limitVisit") || key.equals("limitEdit")
                    || key.equals("runStat")|| key.equals("alarm")|| key.equals("vehicleManager")|| key.equals("deptManager")
                    || key.equals("vehicleEdit")|| key.equals("deptEdit")|| key.equals("userManager")|| key.equals("userEdit")|| key.equals("alarmDelete"))
			    continue;
			String val = (String)entry.getValue();
			if (val.equals("NONE"))
				param.put(key.toString(), null);
			else{
					String[] res = val.split(",");
					List<String> list = new ArrayList<String>();
					for(String rr : res) {
					    if(!rr.equals(""))
                            list.add(rr);
                    }
					param.put(key.toString(), list);
			}
		}
		return param;
	}
}
